package auto;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.UIManager;

public class GlavniFrame extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2014827403421602030L;

	private static GlavniFrame singleFrame = null;
	private JMenuBar menuBar1 = null;
	
	private JMenu file = null;
	
	private JMenu admin = null;
	private JMenuItem help = null;
	private JMenuItem about = null;
	
	private JMenuItem login = null;
	private JMenuItem logout = null;
	
	Smena1Panel smenaPanel = new Smena1Panel();
	Smena2Panel smena2Panel = new Smena2Panel();
	SouthPanel southPanel = new SouthPanel();
	CenterPanel centerPanel = new CenterPanel();
	
	private GlavniFrame() {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception exception){}
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		init();
	
	}

	public void init() {
		
		JPanel glavniPanel = new JPanel();
		setContentPane(glavniPanel);
		BorderLayout br = new BorderLayout();
		setJMenuBar(getMenuBar1());
		glavniPanel.setLayout(br);
		glavniPanel.setBackground(Color.WHITE);
		glavniPanel.add(smenaPanel, BorderLayout.WEST);
		glavniPanel.add(southPanel, BorderLayout.SOUTH);
		glavniPanel.add(smena2Panel, BorderLayout.EAST);
		glavniPanel.add(centerPanel, BorderLayout.CENTER);

	}

	public static GlavniFrame getSingleFrame() {
		if (singleFrame == null) {
			singleFrame = new GlavniFrame();

		}
		return singleFrame;

	}
	


	public JMenuBar getMenuBar1() {
		if (menuBar1 == null) {
			menuBar1 = new JMenuBar();
			menuBar1.add(getFile());
		}
		return menuBar1;
	}

	public JMenu getFile() {
		if(file == null){
			file = new JMenu("File");
			file.add(getAdmin());
			file.add(getHelp());
			file.add(getAbout());
		}
		return file;
	}

	public JMenu getAdmin() {
		if(admin == null){
			admin = new JMenu("Administracija");
			admin.add(getLogin());
			admin.add(getLogout());
			
		}
		return admin;
	}

	public JMenuItem getHelp() {
		if(help == null){
		help = new JMenuItem("Help");
		}
		return help;
	}

	public JMenuItem getAbout() {
		if(about == null){
			about = new JMenuItem("About");
		}
		return about;
	}

	public JMenuItem getLogin() {
		if(login == null){
			login = new JMenuItem("Log in");
		}
		return login;
	}

	public JMenuItem getLogout() {
		if(logout == null){
			logout = new JMenuItem("Log out");
		}
		return logout;
	}
	
	
	
	

}
